# coding=utf-8
"""
使用Flask-WTF实现表单
"""

from flask import Flask, render_template
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, SubmitField
from wtforms.validators import DataRequired, EqualTo

app = Flask(__name__)

app.secret_key = 'secret'


class LoginForm(FlaskForm):
    username = StringField('username', validators=[DataRequired()])
    password = PasswordField('password', validators=[DataRequired()])
    retry_password = PasswordField('retry_password', validators=[DataRequired(), EqualTo('password', 'errorInfo')])
    submit = SubmitField('submit')


@app.route('/form', methods=['GET', 'POST'])
def login():
    login_form = LoginForm()
    return render_template('register_wtf.html', form=login_form)


@app.route('/register', methods=['GET', 'POST'])
def login():
    login_form = LoginForm()

    if login_form.validate_on_submit():
        print("校验全部通过")


if __name__ == '__main__':
    app.run()
